'''
Created on Jun 4, 2012
TC ID: Ecom_5043
Desc: Kiem thu chuc nang xoa chu thich cua mot don vi bai hoc
@author: Vu Dao
'''
import unittest
from Functions.contentFunc import deleteComment, verifyCreateANewComment
import time
from HTMLTestRunner import HTMLTestRunner
from Functions.globalFunc import preCondition, readData, endCondition
from Functions.loginPageFunc import login
from Functions.lessonInformationFunc import clickOnLesson, clickOnContentButton

username=readData("username",index=2)
password=readData("password",index=2)
tm_lesson=readData("lessonName",index=3)
comment=readData("comment")
class Ecom_5043(unittest.TestCase):


    def setUp(self):
        preCondition(self)

    def test_Ecom_5043(self):
        print "Buoc 1: Dang nhap website"
        login(self,username,password)
        
        print "Buoc 2: Click vao bai hoc"
        clickOnLesson(self,tm_lesson)
        
        print "Buoc 3: Click vao Content"
        clickOnContentButton(self)
        
        print "Buoc 4: Xoa mot chu thich cua bai hoc"
        deleteComment(self,comment)
        time.sleep(3)
        print "Buco 5: Kiem tra chu thich da duoc xoa hay chua?"
        self.assertFalse(verifyCreateANewComment(self,comment), "Failed!")
        print "Passed! Module duoc xoa thanh cong"
    
    def tearDown(self):
        endCondition(self)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5043)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang them chu thich cho mot don vi bai hoc'
                    )
    runner.run(suite)